package com.imooc.controller;

import com.imooc.pojo.Users;
import com.imooc.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import java.text.ParseException;

@ApiIgnore
@RestController
public class UsersFooController {

    @Autowired
    private UserService userService;

    @GetMapping("/getUsers")
    public Users getUsers(@RequestParam("id") int id) {
        return userService.getUsersInfo(id);
    }

    @PostMapping("/saveUsers")
    public Object saveUsers() {
        userService.saveUsers();
        return "OK";
    }

    @PostMapping("/updateUsers")
    public Object updateUsers(int id) throws ParseException {
        userService.updateUsers(id);
        return "OK";
    }

    @PostMapping("/deleteUsers")
    public Object deleteUsers(int id) {
        userService.deleteUsers(id);
        return "OK";
    }

}
